package com.example.mardan_demo1.mapper;
import com.example.mardan_demo1.pojo.BuMen;
import com.example.mardan_demo1.pojo.BuMenHeYongHuGuanXi;
import com.example.mardan_demo1.pojo.QiYeYongHu.QiYeYongHu;
import com.example.mardan_demo1.pojo.Result;
import  com.example.mardan_demo1.pojo.User;
import javax.validation.constraints.NotNull;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

@Mapper
public interface UserMapper {
//    根据用户名查询用户
    @Select("select * from user where username = #{username}")
    User findByUserName(String username);

//    添加用户
    @Insert("insert into user(username, password,name,email,userAvatar,status)" +
    "values(#{username},#{password}, #{name}, #{email}, #{userAvatar}, '可用')")
    void add(String username, String password, String name, String email, String userAvatar);
//    更新用户信息
    @Update("update user set name = #{name}, age = #{age}, gender = #{gender}, phone = #{phone}, updatedAt = #{updatedAt}, email = #{email} where id = #{id}")
    void update(User user);

//    更新用户头像
    @Update("update user set userAvatar = #{avatarUrl}  where id = #{id}")
    void updateAvatar(String avatarUrl, Integer id);
//    更新用户密码
    @Update("update user set password = #{password} where id = #{id}")
    void updatePassWord(String password, Integer id);

    User getUserInfo(Integer id);

    User getUserDetail(Integer id);

    Integer updateDetail(User user);

    List<User> getUserList(String name, String userName);

    void buMenXinZeng(String mingCheng, Integer xuHao );

    BuMen getBumenById(Integer bumenId);

    void sheZhiBuMenHeZhiWu(Integer userId, Integer bumenId, String role);

    BuMenHeYongHuGuanXi getBuMenHeYongHuGuanXiByYongHuId(Integer userId);

    List<BuMen> getAllBuMen();

    User getUserInfoByUsername(String username);

    void xinZengYongHu(String name, String username, String password);

    Map<String, Object> adminGetUserById(Integer userId);

    User getUserById(Integer userId);
    void userUpdateDetail(User user);

    void updateUserNickNameAndPasswordById(Integer userId, String name, String password);
    void updateBuMenAndRoleByUserId(Integer userId, Integer bumenId, String role );

    void addQiyeYongHu(QiYeYongHu yonghu);


}
